-
Notifications
You must be signed in to change notification settings - Fork 429
[DO NOT MERGE]bugfix: Prevent Infinite Transaction Cookie Accumulation + Configuration Options #2236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…/nextjs-auth0 into bugfix/txn-cookies-cleanup
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2236 +/- ##
=======================================
Coverage 84.40% 84.41%
=======================================
Files 26 26
Lines 2379 2419 +40
Branches 442 453 +11
=======================================
+ Hits 2008 2042 +34
- Misses 365 371 +6
Partials 6 6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
/** | ||
* The expiration time for transaction cookies in seconds. | ||
* If not provided, defaults to 1 hour (3600 seconds). | ||
* | ||
* @default 3600 | ||
*/ | ||
maxAge?: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make maxAge of txn cookie configurable
This is irrelevant now, see #1917 (comment) |
Fixes transaction cookie accumulation that caused 413 errors when users repeatedly navigate to protected routes. Adds configurable cleanup with three new
AuthClient
options for different application needs.🔍 RCA
Each
startInteractiveLogin()
call created new__txn_*
cookies but only deleted the matching callback cookie, leaving abandoned cookies from incomplete flows to accumulate until hitting HTTP header limits.📋 Changes
Adds configurable transaction cookie management to prevent accumulation while supporting multi-tab scenarios. New
AuthClient
constructor options:enableParallelTransactions: boolean
(default:true
) - Controls single vs multi-transaction modemaxAge
property toTransactionCookieOptions
to control txn cookie maxage (3600s by default)Usage example for single-transaction mode:
Changed
src/server/auth-client.ts
: Added configuration options and cleanup instartInteractiveLogin()
Added
tests/v4-infinitely-stacking-cookies.test.ts
: Comprehensive test coverage for all options📎 References
Fixes: #1917
Fixes: #2209
🎯 Testing
Automated:
Added comprehensive test suite in
tests/v4-infinitely-stacking-cookies.test.ts
covering all configuration options, cleanup scenarios, and edge cases. Fixed CI test failure by providing explicit fetch mock and routes configuration instead of accessing private AuthClient properties.Manual:
enableParallelTransactions: true
enableParallelTransactions: false
pnpm test:unit
to verify all tests pass